#日志类
import logging

class Dolog():
    def getLogger(self,flevel):
        #先申请记录器
        logger=logging.getLogger(__name__)

        #设置日志等级
        logger.setLevel(flevel)
        #设置写去哪里去
        filename=r'F:\work\files\coding\python\2402\webAuto2\Logs\log1.log'

        writeWhere=logging.FileHandler(filename,encoding="utf-8")
        #设置一下写入内容的格式
        fmt = '%(asctime)s-%(filename)s[line:%(lineno)s]-%(levelname)s:%(message)s'
        fmt_str=logging.Formatter(fmt)

        writeWhere.setFormatter(fmt_str)

        logger.addHandler(writeWhere)
        return logger


if __name__=='__main__':
    myLogger=Dolog().getLogger(logging.INFO)
    myLogger.debug("我是debug级别的日志")

